import 'package:flame/components.dart';
import 'package:flame/game.dart';
import 'package:flutter_flame/worlds/game/components/NormalZombie.dart';
import 'package:flutter_flame/worlds/game/components/plants/CommonPlant.dart';
import 'package:flutter_flame/worlds/game/model/PlantModel.dart';

import '../../entity/SpriteAnimationParamEntity.dart';
import '../bullet/Pea.dart';

// 豌豆射手
class PeaShooter extends CommonPlant {
  PeaShooter({
    required super.cell,
  }) : super(
          idleEntity: SpriteAnimationParamEntity.peashooterIdle,
          attackEntity: SpriteAnimationParamEntity.peashooterShoot,
          plantModel: PlantModel.peashooter,
          shootDelayTime: Duration(milliseconds: 500),
        );

  @override
  Future<void> attack(NormalZombie zombie) {
    world.add(Pea(position: position + Vector2(15, -8)));
    return super.attack(zombie);
  }
}
